#pragma once
#include<vector>
#include<functional>
#include <chrono> // 可选，头文件已包含
class TcpConnection; // 前置声明
class TimerHeap
{
public:
    std::vector<TcpConnection*> heap;
    TimerHeap();
    ~TimerHeap();
   //     比较函数：按expire_time排序
    static bool cmp(TcpConnection* a, TcpConnection* b);
    void push(TcpConnection* conn);
    void remove(TcpConnection* conn);
    void update(TcpConnection* conn, std::chrono::steady_clock::time_point new_expire);
    TcpConnection* top();
    void pop();
    bool empty() const;
    size_t size() const;
private:

    void up(size_t idx);
    void down(size_t idx);
};